﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimaryAlgorithm.RotatePhoto
{
    /// <summary>
    /// 举证的转置
    /// </summary>
    class MainProject
    {
        static void Main(string[] args)
        {
            int[][] board = new int[][] { 
                new int[] {5,1,9,11},
                new int[] {2,4,8,10 },
                new int[] {13,3,6,7 },
                new int[] {15,14,12,16 },
            };
            Rotate(board);
            //foreach (var item in nums)
            //{
            //    Console.WriteLine(item);
            //}
            Console.ReadKey();
        }
        public static void Rotate(int[][] matrix)
        {
            int xTrans = 0;
            int yTrans = 0;
            Queue<int[]> vs = new Queue<int[]>();
            if (matrix.Length>1)
            {
                for (int i = 0; i < matrix.Length; i++)
                {
                    for (int j = 0; j < matrix[i].Length; j++)
                    {
                        vs.Enqueue(new int[] { matrix[i][j], i, j });
                    }
                }
                while (vs.Count > 0)
                {
                    int[] data = vs.Dequeue();
                    xTrans = data[2];
                    yTrans = matrix.Length - 1 - data[1];

                    matrix[xTrans][yTrans] = data[0];

                }
            }
        }
    }
}
